package com.zhuzi.config;

import com.zhuzi.jpa.ann.CommentIntegrator;
import org.hibernate.jpa.boot.spi.IntegratorProvider;
import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.Map;

@Component
public class HibernateConfig implements HibernatePropertiesCustomizer {
    /**
     * Customize the specified JPA vendor properties.
     *
     * @param hibernateProperties the JPA vendor properties to customize
     */
    @Override
    public void customize(Map<String, Object> hibernateProperties) {
        hibernateProperties.put("hibernate.use_sql_comments", true);
        hibernateProperties.put("spring.jpa.hibernate.ddl-auto", true);
        hibernateProperties.put("hibernate.integrator_provider",
                (IntegratorProvider) () -> Collections.singletonList(CommentIntegrator.INSTANCE));

    }
}
